﻿using Alos.Common;
using Alos.Entity;
using Alos.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;

namespace Alos.LanClass.Api
{
    /// <summary>
    /// 章节信息获取
    /// </summary>
    public class ChapterController : ApiController
    {
        IChapterService ChapterService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_ChapterService"></param>
        public ChapterController(IChapterService _ChapterService)
        {
            ChapterService = _ChapterService;
        }
        /// <summary>
        /// 根据教材编号获取教材章节
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("api/Chapter/find")]
        public async Task<JsonRtn<List<dynamic>>> find(int id)
        {
            var jsRtn = new JsonRtn<List<dynamic>>();
            jsRtn.data = await Task.Factory.StartNew(mid =>
            {
                return ChapterService.GetChapterByMid((int)mid).ToList();
            }, id);
            return jsRtn;
        }
    }
}